<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DocumentTwo2</title>
    <script src="innerjs.js"></script>
</head>

<body>
    <script>
        console.log(hello)
        var hello = 200;
        // 使用冒泡方法对数据进行排序          
        function bubbleSort(arr) {
            let len = arr.length;
            for (let i = 0; i < len - 1; i++) {
                for (let j = 0; j < len - 1 - i; j++) {
                    if (arr[j] > arr[j + 1]) {
                        // 交换位置
                        [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
                    }
                }
            }
            return arr;
        }

        // 测试冒泡排序
        let arr = [5, 3, 8, 4, 2]; 
        console.log("原数组:", arr);    
        let sortedArr = bubbleSort(arr);
        console.log("排序后数组:", sortedArr);  
        
    </script>
</body>


</html>
